﻿<Window x:Class="DotNetNinjaLibrary.TestApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:local="clr-namespace:DotNetNinjaLibrary.TestApplication"
		xmlns:library="clr-namespace:DotNetNinjaLibrary;assembly=DotNetNinjaLibrary"
        Title="MainWindow" Height="350" Width="525" MouseLeftButtonDown="Window_MouseLeftButtonDown" MouseRightButtonDown="Window_MouseRightButtonDown" MouseRightButtonUp="Window_MouseRightButtonUp">
    <Grid>
		<Grid.Resources>
			<DataTemplate x:Key="UnitTemplate" DataType="library:Unit">
				<Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="Red"/>
			</DataTemplate>
			<DataTemplate x:Key="HeroTemplate" DataType="library:Hero">
				<Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="Blue"/>
			</DataTemplate>
		</Grid.Resources>
		<local:MapRenderingItemsControl x:Name="control">
			<local:MapRenderingItemsControl.Template>
				<ControlTemplate TargetType="ItemsControl">
					<Grid>
						<ItemsPresenter x:Name="ItemsPanel" />
					</Grid>
				</ControlTemplate>
			</local:MapRenderingItemsControl.Template>
			<local:MapRenderingItemsControl.ItemsPanel>				
				<ItemsPanelTemplate>
					<Grid />
				</ItemsPanelTemplate>
			</local:MapRenderingItemsControl.ItemsPanel>
			<local:MapRenderingItemsControl.ItemContainerStyle>
				<Style TargetType="ContentPresenter">
					<Setter Property="Grid.Row" Value="{Binding Location.Y}" />
					<Setter Property="Grid.RowSpan" Value="{Binding Size.Height}" />
					<Setter Property="Grid.Column" Value="{Binding Location.X}" />
					<Setter Property="Grid.ColumnSpan" Value="{Binding Size.Width}" />
				</Style>
			</local:MapRenderingItemsControl.ItemContainerStyle>
			<local:MapRenderingItemsControl.ItemTemplateSelector>
				<local:UniteTemplateSelector UnitTemplate="{StaticResource UnitTemplate}" HeroTemplate="{StaticResource HeroTemplate}" />
			</local:MapRenderingItemsControl.ItemTemplateSelector>
		</local:MapRenderingItemsControl>
	</Grid>
</Window>
